<?php 
require_once 'header.php';
require "backend/Customer.php";
?>
	
	<div id = "pagecontent">
	<?php
		if(isset($_POST['Email']))
		{
			$usermail = ($_POST['Email']);
			$password = ($_POST['Password']);
			if($usermail == "" || $password == "")
			{
				echo "<font size=3 color=red><b>Not all fields were entered</b><p/></font><br/>";
			}
			else
			{
				$login = new Customer();
				$customer = $login->getCustomer($usermail,$password);
			
				$username = $customer->getUsername();
				$userpass = $customer->getPassword();
				if($username == $usermail && $password == $userpass)
				{
					$_SESSION['customer'] = serialize($customer);
					echo "<script language='JavaScript'>window.location.href='Menu.php'</script>";
				}
				else {
					echo "<font size='3' color='red'><b>email and password is incorrect</b><p/></font><br/>";
				}
			}
		}

	if(isset($_SESSION['customer']))
	{
		echo "<font size='3' color='green'><b>You are already signed in please click <a href='index.php'>here.</a></font>";
	}
	else
	{
		
	
	?>
	<form action="Login.php" method="post">
		<fieldset>
		<h1>LOGIN PAGE</h1>
		<br><br>
		<div id = "Email">
			<font color = "red" size = "3">Email : <p/></font>
			<input  name="Email" type="text">
			
		</div>
		<div id = "Password">
			<font color = "red" size = "3">Password : <p/></font>
			<input  name="Password" type="password">
	     
		</div>
		
		<p><input type="submit" value="Log On" /></p>
		</fieldset>
	</form>
	</div>

<?php
	}
require_once 'footer.php';?>